import { request } from '@umijs/max';
import { PageResponse } from './index';

// 荣誉信息接口
export interface HonorInfo {
  id?: number;
  name: string;
  description?: string;
  awardDate?: number | string;
  famousPersonId: number;
}

// 分页查询请求
export interface HonorPageRequest {
  pageCurrent: number;
  pageSize: number;
  famousPersonId: number;
  keyword?: string;
  startDate?: string;
  endDate?: string;
}

// API接口
export async function getHonorPage(params: HonorPageRequest) {
  return request<PageResponse<HonorInfo>>('/honor-info/page', {
    method: 'POST',
    data: params,
  });
}

export async function addHonor(data: Omit<HonorInfo, 'id'>) {
  return request('/honor-info/back', {
    method: 'POST',
    data,
  });
}

export async function updateHonor(data: HonorInfo) {
  return request('/honor-info/back', {
    method: 'PUT',
    data,
  });
}

export async function deleteHonor(idList: number[]) {
  const ids = idList.join(',');
  return request(`/honor-info/back/${ids}`, {
    method: 'DELETE',
  });
}